﻿using System;
using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace GenCode
{
    class Misc
    {
        #region data type list
        private static Hashtable htType = null;
        public static Hashtable Types
        {
            get
            {
                if (htType == null) Type_Init();
                return htType;
            }
        }
        private static void Type_Init()
        {
            htType = new Hashtable();
            htType.Add("N", "Int32");
            htType.Add("Z", "Int32");
            htType.Add("R", "Double");
            htType.Add("B", "Boolean");
            htType.Add("Char", "char");
            htType.Add("R*", "Double[]");
        }
        #endregion

        #region operator list
        private static Hashtable htOperators = null;
        public static Hashtable Operators
        {
            get
            {
                if (htOperators == null) Operator_Init();
                return htOperators;
            }
        }
        private static void Operator_Init()
        {
            htOperators = new Hashtable();
            htOperators.Add("==", CodeBinaryOperatorType.IdentityEquality);
            htOperators.Add("!=", CodeBinaryOperatorType.IdentityInequality);
            htOperators.Add(">", CodeBinaryOperatorType.GreaterThan);
            htOperators.Add("<", CodeBinaryOperatorType.LessThan);
            htOperators.Add(">=", CodeBinaryOperatorType.GreaterThanOrEqual);
            htOperators.Add("<=", CodeBinaryOperatorType.LessThanOrEqual);
            htOperators.Add("/\\", CodeBinaryOperatorType.BooleanAnd);
            htOperators.Add("\\/", CodeBinaryOperatorType.BooleanOr);
            htOperators.Add("+", CodeBinaryOperatorType.Add);
            htOperators.Add("-", CodeBinaryOperatorType.Subtract);
            htOperators.Add("*", CodeBinaryOperatorType.Multiply);
            htOperators.Add("/", CodeBinaryOperatorType.Divide);
            htOperators.Add("%", CodeBinaryOperatorType.Modulus);
            htOperators.Add("=", CodeBinaryOperatorType.Assign);
        }
        #endregion

        #region error value
        private static Hashtable htErr = null;
        public static Hashtable Error
        {
            get
            {
                if (htErr == null) Err_Init();
                return htErr;
            }
        }
        private static void Err_Init()
        {
            htErr = new Hashtable();
            htErr.Add("N", 0);
            htErr.Add("Z", -1);
            htErr.Add("R",  -1);
            htErr.Add("B", false);
            htErr.Add("Char", null);
        }
        #endregion

    }
}